package com.shop2cn.iapi.member.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.MchSeRegTermBean;
import com.shop2cn.iapi.member.service.MchSeRegTermCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmember.MchMemberConfig;
import com.ymttest.database.sqlwapper.godmember.GodMemberWapper;
/**
*商家设置会员注册条款
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_MchSeRegTerm{
	private static MchSeRegTermBean mchseregtermBean;
	private static MchSeRegTermCall mchseregtermCall;
	static GodMemberWapper GodMemberWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商家设置会员注册条款");
		GodMemberWapper=new GodMemberWapper();
	}

	@Before
	public void caseUp() {
		mchseregtermBean=new MchSeRegTermBean();
		mchseregtermCall=new MchSeRegTermCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(mchseregtermCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_MchSeRegTerm_001() {
		Logger.start(true,"商家设置会员注册条款成功");
		try {
			Integer shopid = GodmchManageCallService.CreateSellerMch();
			mchseregtermBean.setDefaultRegTerm(true);
			mchseregtermBean.setShopId(shopid);
			mchseregtermCall.setData(mchseregtermBean);
			mchseregtermCall.callService();			
			Logger.verifyEquals("200", mchseregtermCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchseregtermCall.getString("data"), "验证data");
			MchMemberConfig conf = GodMemberWapper.selectMchMemberConfigByShopId(mchseregtermBean.getShopId());
			Logger.verifyEquals(mchseregtermBean.getDefaultRegTerm(), conf.getDefaultRegTerm(), "验证getDefaultRegTerm");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSeRegTerm_002() {
		Logger.start(true,"不输入defaultRegTerm失败");
		try {
//			mchseregtermBean.setDefaultRegTerm(true);
			mchseregtermBean.setShopId(1);
			mchseregtermCall.setData(mchseregtermBean);
			mchseregtermCall.callService();			
			Logger.verifyEquals("400", mchseregtermCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_MchSeRegTerm_003() {
		Logger.start(true,"不输入shopId失败");
		try {
			mchseregtermBean.setDefaultRegTerm(true);
//			mchseregtermBean.setShopId(1);
			mchseregtermCall.setData(mchseregtermBean);
			mchseregtermCall.callService();			
			Logger.verifyEquals("400", mchseregtermCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_MchSeRegTerm_004() {
		Logger.start(true,"商家设置会员注册条款成功,false");
		try {
			Integer shopid = GodmchManageCallService.CreateSellerMch();
			mchseregtermBean.setDefaultRegTerm(false);
			mchseregtermBean.setShopId(shopid);
			mchseregtermCall.setData(mchseregtermBean);
			mchseregtermCall.callService();			
			Logger.verifyEquals("200", mchseregtermCall.getString("code"), "验证code");
			Logger.verifyEquals("true", mchseregtermCall.getString("data"), "验证data");
			MchMemberConfig conf = GodMemberWapper.selectMchMemberConfigByShopId(mchseregtermBean.getShopId());
			Logger.verifyEquals(mchseregtermBean.getDefaultRegTerm(), conf.getDefaultRegTerm(), "验证getDefaultRegTerm");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}